#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include "AStarSolver.h"
#include <QMainWindow>
#include "gui/GraphicsSquare.h"

QT_BEGIN_NAMESPACE
namespace Ui {
class MainWindow;
}
QT_END_NAMESPACE

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    MainWindow(QWidget *parent = nullptr);
    ~MainWindow();

public slots:
    void stepped();
    void goStep();
    void start();
    void stop();
    void updateTask(int);
    void switchMode();
    void dragTask(const QList<QRectF> &);

private:
    Ui::MainWindow *ui;
    AStarSolver *solver;

    Location src;
    Location dst;

    QGraphicsPixmapItem *srcItem;
    QGraphicsPixmapItem *dstItem;

    void updateViewSize();
    void resetSquare();
    void updateSquare();
    GraphicsSquare *findSquare(int x, int y);
    void setSrcDstItem();
    // QWidget interface
protected:
    void resizeEvent(QResizeEvent *event);
    void closeEvent(QCloseEvent *event);
};
#endif // MAINWINDOW_H
